#include "ros/ros.h"
#include "std_msgs/String.h"
#include <sstream>
 void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
  ROS_INFO("CatchMsg2: [%s]", msg->data.c_str());
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "msg");
  ros::NodeHandle n;
  ros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter1", 1000);
  ros::Subscriber sub = n.subscribe("chatter2", 1000, chatterCallback);
  ros::Rate loop_rate(1);
  
  int count = 0;
  while (ros::ok())
  {
    std_msgs::String msg;
    std::stringstream ss;
    ss << "xiawangwang " << count;
    msg.data = ss.str();
    chatter_pub.publish(msg);
    ros::spinOnce();
    loop_rate.sleep();
    ++count;
 }
 return 0;
}
